package com.zhihui.client.alarm.controller;

import com.zhihui.client.alarm.common.Lay;
import com.zhihui.client.alarm.common.Msg;
import com.zhihui.client.alarm.entity.User;
import com.zhihui.client.alarm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController2 {
    @Autowired
    private UserService userService;

    @RequestMapping
    public String user(){
        return "user/user.html";
    }
    @RequestMapping("/add")
    public String add(){
        return "user/addUser.html";
    }

    @RequestMapping("/update")
    public String update(){
        return "user/updateUser.html";
    }

    @RequestMapping("/getUsers")
    @ResponseBody
    public Lay getUsers(User user, Integer page, Integer limit){
        return userService.getUsers(user,page,limit);
    }
    @RequestMapping("/addUser")
    @ResponseBody
    public Msg addUser(User user){
        return userService.addUser(user);
    }

    @RequestMapping("/updateUser")
    @ResponseBody
    public Msg updateUser(User user){
        return userService.updateUser(user);
    }

    @RequestMapping("/delUser")
    @ResponseBody
    public Msg delUser(User user){
        return userService.delUser(user);
    }
}